package com.ktwlsoft.archivemanage.controller.dataProfile;

import com.ktwlsoft.archivemanage.domain.business.repositoryService.view.MendDataProfileRepositoryService;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Year;

@Api("整改分析")
@RestController
@RequestMapping("/mendDataProfile")
public class MendDataProfileController {

    private final MendDataProfileRepositoryService mendDataProfileRepositoryService;

    public MendDataProfileController(MendDataProfileRepositoryService mendDataProfileRepositoryService) {
        this.mendDataProfileRepositoryService = mendDataProfileRepositoryService;
    }

    @ApiOperation("超期未整改预警")
    @GetMapping("/getExceed")
    public ResponseEntity<?> getExceed() {
        return ResponseEntity.ok(Result.ok(mendDataProfileRepositoryService.getExceed()));
    }

    @ApiOperation("整改次数列表")
    @GetMapping("/getMendTimes")
    public ResponseEntity<?> getMendTimes(@RequestParam Year year) {
        return ResponseEntity.ok(Result.ok(mendDataProfileRepositoryService.getProfileMendTimesMapper().selectAll(year)));
    }


    @ApiOperation("立档单位检查整改次数历年变化趋势")
    @GetMapping("/getMendTimesVariation")
    public ResponseEntity<?> getMendTimesVariation(){
        return ResponseEntity.ok(Result.ok(mendDataProfileRepositoryService.getProfileMendTimesVariationMapper().selectAll()));
    }
}
